package cn.qingxuntech.console.controller

import cn.qingxuntech.console.entity.CalcDayReport
import cn.qingxuntech.console.entity.CalcHourReport
import cn.qingxuntech.console.entity.MediaIncome
import cn.qingxuntech.console.entity.MediaIncomeShow
import cn.qingxuntech.console.entity.SspMedia
import cn.qingxuntech.console.model.R
import cn.qingxuntech.console.model.request.ReportRequest
import cn.qingxuntech.console.model.response.PriceStat
import cn.qingxuntech.console.model.response.WeekStat
import cn.qingxuntech.console.service.ReportService
import com.mybatisflex.core.paginate.Page
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/qx/console/v1/report")
class ReportController {

    @Autowired
    lateinit var reportService: ReportService

    @PostMapping("calcHourPage")
    fun calcHourPage(@RequestBody reportRequest: ReportRequest): R<Page<CalcHourReport>> {

        return R.success(reportService.calcHourPage(reportRequest))
    }

    @PostMapping("calcDayPage")
    fun calcDayPage(@RequestBody reportRequest: ReportRequest): R<Page<CalcDayReport>> {

        return R.success(reportService.calcDayPage(reportRequest))
    }

    @PostMapping("calcSpaceDay")
    fun calcSpaceDay(@RequestBody reportRequest: ReportRequest): R<List<CalcDayReport>> {

        return R.success(reportService.calcSpaceDay(reportRequest))
    }

    @PostMapping("calcSpaceHour")
    fun calcSpaceHour(@RequestBody reportRequest: ReportRequest): R<List<CalcHourReport>> {

        return R.success(reportService.calcSpaceHour(reportRequest))
    }

    @PostMapping("calcHourCompare")
    fun calcHourCompare(@RequestBody reportRequest: ReportRequest): R<List<CalcHourReport>> {

        return R.success(reportService.calcHourCompare(reportRequest))
    }

    @GetMapping("weekStat")
    fun weekStat(): R<List<WeekStat>> {

        return R.success(reportService.weekStat())
    }

    @GetMapping("twoDay")
    fun twoDay(): R<List<PriceStat>> {

        return R.success(reportService.twoDay())
    }

    @PostMapping("qsMediaIncome")
    fun qsMediaIncome(@RequestBody reportRequest: ReportRequest): R<List<MediaIncomeShow>> {

        return R.success(reportService.qsMediaIncome(reportRequest))
    }
}
